/**
 * Historico de alteração
 *
 * Data         Autor   Descrição
 * 24/10/2010   Jerry   Criação do cabeçalho.
 *
 */

package Instrumentos;



import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Point;

import javax.swing.JFrame;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.dial.ArcDialFrame;
import org.jfree.data.general.DefaultValueDataset;
import org.jfree.chart.plot.dial.DialBackground;
import org.jfree.chart.plot.dial.DialPlot;
import org.jfree.chart.plot.dial.DialPointer;
import org.jfree.chart.plot.dial.StandardDialScale;
import org.jfree.ui.GradientPaintTransformType;
import org.jfree.ui.StandardGradientPaintTransformer;


public class Amperimetro extends JFrame implements ChangeListener {

    /** The dataset. */
    DefaultValueDataset dataset;

    /**
     * Creates a new instance.
     *
     * @param title the frame title.
     */
    public Amperimetro(String title) {
        super(title);
        this.dataset = new DefaultValueDataset(50);
        // get data for diagrams
        DialPlot plot = new DialPlot();
        plot.setView(0, -0.20, 1, 0.9);
        plot.setDataset(this.dataset);

        ArcDialFrame dialFrame = new ArcDialFrame(-10.0, 200.0);
        

        dialFrame.setInnerRadius(0.1);
        dialFrame.setOuterRadius(0.92);
        dialFrame.setForegroundPaint(Color.darkGray);
        dialFrame.setBackgroundPaint(Color.white);
        dialFrame.setStroke(new BasicStroke(3.0f));
        plot.setDialFrame(dialFrame);

        GradientPaint gp = new GradientPaint(new Point(),
                new Color(255, 255, 255), new Point(),
                new Color(240, 240, 240));
        DialBackground sdb = new DialBackground(gp);
        sdb.setGradientPaintTransformer(new StandardGradientPaintTransformer(
                GradientPaintTransformType.VERTICAL));
        plot.addLayer(sdb);


        StandardDialScale scale = new StandardDialScale(0, 500, -180D, -180D, 100, 5);

        scale.setTickRadius(0.87);
        scale.setTickLabelOffset(0.07);
        scale.setTickLabelPaint(Color.BLUE);
        plot.addScale(0, scale);
        DialPointer needle = new DialPointer.Pin();
        needle.setRadius(0.82);
        plot.addLayer(needle);
        JFreeChart chart1 = new JFreeChart(plot);
        chart1.setTitle("Amperímetro - A");
        ChartPanel cp1 = new ChartPanel(chart1);

        cp1.setPreferredSize(new Dimension(400, 250));

        add(cp1);


    }
     public void stateChanged(ChangeEvent e) {}

     public void setValor(double valor) {
         this.dataset.setValue(valor);
         
     }

 }


